package com.maxd.modules.coupon.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @Auther: Laban:yubo_010@163.com
 * @Date: 2020/11/13 14:20
 * @Description:
 */
@Data
@Entity
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Table(name = "sqx_coupon_amount")
@ApiModel(value = "sqx_coupon_amount对象", description = "用户优惠金额管理")
public class CouponAmount implements Serializable {

    @Id()
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    /**主键ID*/
    private Long id;

    @Column(name = "create_time")
    /**创建时间*/
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    private java.util.Date createTime;

    @Column(name = "user_id")
    /**用户ID*/
    private String userId;

    @Column(name = "user_deduct_quota")
    /**用户抵扣总额度(单位 分)*/
    private String userDeductQuota;

    @Column(name = "user_province_amount")
    /**用户节省总额(单位 分)*/
    private String userProvinceAmount;

    @Column(name = "user_frozen_amount")
    /**用户冻结金额(单位 分)*/
    private String userFrozenAmount;


    public CouponAmount saveCouponAmount(Date date,String userId,String userDeductQuota,String userProvinceAmount,String userFrozenAmount){
        CouponAmount couponAmount = new CouponAmount();
        couponAmount.setCreateTime(date);
        couponAmount.setUserId(userId);
        couponAmount.setUserDeductQuota(userDeductQuota);
        couponAmount.setUserProvinceAmount(userProvinceAmount);
        couponAmount.setUserFrozenAmount(userFrozenAmount);
        return couponAmount;
    }

    public CouponAmount saveCouponAmountNoDate(String userId,String userDeductQuota,String userProvinceAmount,String userFrozenAmount){
        CouponAmount couponAmount = new CouponAmount();
        couponAmount.setUserId(userId);
        couponAmount.setUserDeductQuota(userDeductQuota);
        couponAmount.setUserProvinceAmount(userProvinceAmount);
        couponAmount.setUserFrozenAmount(userFrozenAmount);
        return couponAmount;
    }

}
